/**
 * Created by bdbs on 2017/6/19.
 */
const electron = require('electron');
const path = require('path');
const { app, BrowserWindow, Tray, Menu, ipcMain } = electron;
const TimerTray = require('./app/TimerTray.js');
const MainWindow = require('./app/MainWindow.js');

let mainWindow;

app.on('ready', () => {
  app.dock.hide();
  mainWindow = new MainWindow(`file://${__dirname}/app/main.html`);

  const iconName = process.platform === 'darwin' ? 'iconTemplate.png' : 'windows-icon@2x.png';
  const iconPath = path.join(__dirname, `./app/assets/${iconName}`);
  const timerTray = new TimerTray(iconPath, mainWindow);

  ipcMain.on('update-timer', (evnet, count) => {
    timerTray.setTitle(`timer${count}`);
  });
});
